package Screens;

import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;

import Paineis.ToolTypes;
import Utils.Constantes;
import Utils.Utilidades;

public class TelaTorresLiberada extends Screen {	
	
	public int quantidadeDetorresLiberada;
	int i, j;
	int posX; 
	int sizeX;
	int sizeY;
	int indice;
	ArrayList<ToolTypes>listaDeStatusTorres;
	boolean mostraToolType;
	

	public TelaTorresLiberada(int X, int Y, int Width, int Height,
			String fileNome) {
		super(X, Y, Width, Height, fileNome);
		// TODO Auto-generated constructor stub
		sizeX = 75;
		sizeY = 150;
		quantidadeDetorresLiberada =3;
		listaDeStatusTorres = new ArrayList<ToolTypes>();
		for(int i=0; i<11; i++){
			listaDeStatusTorres.add(new ToolTypes(0, 0, "status"+i+".png"));
		}

		
	}

	public TelaTorresLiberada() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void Draw(Graphics2D dbg) {
		// TODO Auto-generated method stub
	
			dbg.drawImage(fundo, 0, 0, null);
			for(i=0; i<quantidadeDetorresLiberada; i++){
				if(i<6){
					dbg.drawImage(Constantes.listaDeBuildsTorres.get(i), 100+(i*125), 115, null);
				}else{
					dbg.drawImage(Constantes.listaDeBuildsTorres.get(i), 100+((i%6)*125), 290, null);
				}
			}
			if(mostraToolType){
				listaDeStatusTorres.get(indice).draw(dbg);
			}
			
		

	}
	
	public void adicionaTorres(){
		
	}

	@Override
	public void Update(long diffTime) {
		// TODO Auto-generated method stub

	}

	@Override
	public void tratadorTecladoPress(KeyEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void tratadorTecladoReleased(KeyEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseMoved(MouseEvent e) {
		mostraToolType = false;
		for(j=0; j<quantidadeDetorresLiberada; j++){
			if(j<6){
				posX =100+(j*125);
				if(Utilidades.ColisaoRetangular(posX, 115, posX+sizeX, 115+sizeY, e.getX(), e.getY(), e.getX()+1, e.getY()+1)){
					indice = j;
					listaDeStatusTorres.get(j).setPosition(e.getX(), e.getY());
					mostraToolType = true;
				}
			
			}else{
				posX= 100+((j%6)*125);
				if(Utilidades.ColisaoRetangular(posX, 290, posX+sizeX, 290+sizeY, e.getX(), e.getY(), e.getX()+1, e.getY()+1)){
					indice = j;
					listaDeStatusTorres.get(j).setPosition(e.getX(), e.getY());
					mostraToolType = true;
				}
			
			}
		}
		
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setaOpcao(int opcao) {
		// TODO Auto-generated method stub

	}

}
